# 封装公共操作（登录、元素等待）
class AdminPage:
    def __init__(self, driver):
        self.driver = driver
        
    def wait_element(self, locator, timeout=10):
        return WebDriverWait(self.driver, timeout).until(
            EC.presence_of_element_located(locator)
        )
    
    def login(self, username, password):
        self.driver.get("https://admin.example.com/login")
        self.wait_element((By.ID, "username")).send_keys(username)
        self.driver.find_element(By.ID, "password").send_keys(password)
        self.driver.find_element(By.XPATH, "//button[text()='登录']").click()

# 使用示例
driver = webdriver.Chrome()
admin = AdminPage(driver)
admin.login("admin", "Admin@123")